Set stdin/stdout to binary mode if __WIN32__.
authoroliskoli <oliskoli@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 13 Aug 2006 18:26:18 +0000 (18:26 +0000)
committeroliskoli <oliskoli@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 13 Aug 2006 18:26:18 +0000 (18:26 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@2296 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/gbfile.c

index 30283d96ec44e852f338034aa8ae8bad1de4f536..35748b776698e3a02d43f0f4958778955ab2064c 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+
+#if __WIN32__
+/* taken from minigzip.c (part of the zlib project) */
+#  include <fcntl.h>
+#  include <io.h>
+#  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
+#else
+#  define SET_BINARY_MODE(file)
+#endif
+
 #define MYNAME "gbfile"
 
 /* About the ZLIB_INHIBITED stuff:
@@ -94,6 +104,7 @@ gbfopen(const char *filename, const char *mode, const char *module)
                                fd = stdin;
                        else
                                fd = stdout;
+                       SET_BINARY_MODE(fd);
                        file->handle.gz = gzdopen(fileno(fd), openmode);
                }
                else